#include <util\AutomaticInstallation.au3>

Global $InstallProgramPath = "C:\Perl\bin\perl.exe"
Global $InstallFolder      = "C:\Perl"

Global $SetupFile = "ActivePerl-5.10.1.1007-MSWin32-x86-291969.msi"
Global $UninstallPath = ""

Main($InstallProgramPath, $InstallFolder, $SetupFile, $UninstallPath)

Func InstallImpl($SetupPath) 
	Dim $Title = ""
	
	RunSetupFile($SetupPath)

	$Title = "ActivePerl 5.10.1 Build 1007 Setup"
	WinWaitActive($Title)
	Send("!N")
	Sleep($SleepDelay)
	
	; Welcome message
	$Title = "ActivePerl 5.10.1 Build 1007 License Agreement"
	WinWaitActive($Title)
	Send("{UP}")
	Sleep($SleepDelay)
	Send("!N")
	Sleep($SleepDelay)
	
	; choose install directory
	$Title = "ActivePerl 5.10.1 Build 1007 Setup"
	WinWaitActive($Title)
	Send("!N")
	Sleep($SleepDelay)
	
	$Text = "Add Perl to the PATH environment variable"
	WinWaitActive($Title, $Text)
	Send("!N")
	Sleep($SleepDelay)
	
	$Text = "Ready to Install"
	WinWaitActive($Title, $Text)
	Send("!I")
	Sleep($SleepDelay)
	
	$Text = "&Finish"
	WinWaitActive($Title, $Text)
	Send("+{TAB}")
	Send("{SPACE}")
	Send("!F")
	Sleep($SleepDelay)
	
	WinWaitClose($Title)

	Return True
EndFunc

Func UninstallImpl($UninstallPath)
	Dim $Title = ""

	$UninstallPath = "MsiExec.exe /I{F7B9B60F-DBB3-4116-967B-BA93E278331E}"
	RunSetupFile($UninstallPath)

	$Title = "ActivePerl 5.10.1 Build 1007 Setup"
	WinWaitActive($title)
	Send("!N")
	Sleep($SleepDelay)

	$Title = "ActivePerl 5.10.1 Build 1007 Setup"
	$Text = "Modify, Repair or Remove installation"
	WinWaitActive($title,$Text)
	Send("{TAB}")
	Send("{TAB}")
	Send("{SPACE}")
	Sleep($SleepDelay)

	$Text = "Remove ActivePerl 5.10.1 Build 1007?"
	WinWaitActive($title,$Text)
	Send("!R")
	Sleep($SleepDelay)
	
	$Text = "&Finish"
	WinWaitActive($Title, $Text)
	Send("!F")
	Sleep($SleepDelay)

	Return True
EndFunc




